-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add functional test for java-spiffe-helper #207
Add functional test for java-spiffe-helper #207
Conversation
ac58a5b
to
d2c5d32
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. :)
One possible change inline.
Looks good to me. :) |
dfc4a16
to
0158e34
Compare
Signed-off-by: Moritz Schmitz von Hülst <[email protected]>
Signed-off-by: Moritz Schmitz von Hülst <[email protected]>
Signed-off-by: Moritz Schmitz von Hülst <[email protected]>
Signed-off-by: Moritz Schmitz von Hülst <[email protected]>
Signed-off-by: Moritz Schmitz von Hülst <[email protected]>
0158e34
to
b71d80a
Compare
.github/workflows/test.yaml
Outdated
@@ -0,0 +1,59 @@ | |||
name: Test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name: Test | |
name: Java SPIFFE Helper CI |
.github/workflows/test.yaml
Outdated
- if: ${{ failure() }} | ||
run: kubectl logs pod/java-spiffe-helper | tee java-spiffe-helper.log | ||
- if: ${{ failure() }} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: logs | ||
path: java-spiffe-helper.log | ||
- if: ${{ failure() }} | ||
run: kubectl describe pod/java-spiffe-helper | ||
- uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '17' | ||
- run: kubectl cp java-spiffe-helper:/tmp/keystore.p12 keystore.p12 | ||
- run: kubectl cp java-spiffe-helper:/tmp/truststore.p12 truststore.p12 | ||
- run: keytool -v -list -keystore keystore.p12 -storepass password | grep "CN=${{ env.KEYSTORE_COMMON_NAME }}" | ||
- if: ${{ failure() }} | ||
run: keytool -v -list -keystore keystore.p12 -storepass password | ||
- run: keytool -v -list -keystore truststore.p12 -storepass password | grep "CN=${{ env.TRUSTSTORE_COMMON_NAME }}" | ||
- if: ${{ failure() }} | ||
run: keytool -v -list -keystore truststore.p12 -storepass password |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest adding step names to improve clarity, something like:
- if: ${{ failure() }} | |
run: kubectl logs pod/java-spiffe-helper | tee java-spiffe-helper.log | |
- if: ${{ failure() }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: logs | |
path: java-spiffe-helper.log | |
- if: ${{ failure() }} | |
run: kubectl describe pod/java-spiffe-helper | |
- uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- run: kubectl cp java-spiffe-helper:/tmp/keystore.p12 keystore.p12 | |
- run: kubectl cp java-spiffe-helper:/tmp/truststore.p12 truststore.p12 | |
- run: keytool -v -list -keystore keystore.p12 -storepass password | grep "CN=${{ env.KEYSTORE_COMMON_NAME }}" | |
- if: ${{ failure() }} | |
run: keytool -v -list -keystore keystore.p12 -storepass password | |
- run: keytool -v -list -keystore truststore.p12 -storepass password | grep "CN=${{ env.TRUSTSTORE_COMMON_NAME }}" | |
- if: ${{ failure() }} | |
run: keytool -v -list -keystore truststore.p12 -storepass password | |
- name: Capture Pod Logs on Failure | |
if: ${{ failure() }} | |
run: kubectl logs pod/java-spiffe-helper | tess java-spiffe-helper.log | |
- name: Upload Pod Logs on Failure | |
if: ${{ failure() }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: java-spiffe-helper-logs | |
path: java-spiffe-helper.log | |
- name: Describe Pod on Failure | |
if: ${{ failure() }} | |
run: kubectl describe pod/java-spiffe-helper | |
- name: Setup Java Environment | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: Copy Keystore and Truststore from Pod | |
run: | | |
kubectl cp java-spiffe-helper:/tmp/keystore.p12 keystore.p12 | |
kubectl cp java-spiffe-helper:/tmp/truststore.p12 truststore.p12 | |
- name: Verify Keystore Common Name | |
run: keytool -v -list -keystore keystore.p12 -storepass ${{ secrets.KEYSTORE_PASSWORD }} | grep "CN=${{ env.KEYSTORE_COMMON_NAME }}" | |
if: ${{ failure() }} | |
run: keytool -v -list -keystore keystore.p12 -storepass ${{ secrets.KEYSTORE_PASSWORD }} | |
- name: Verify Truststore Common Name | |
run: keytool -v -list -keystore truststore.p12 -storepass ${{ secrets.TRUSTSTORE_PASSWORD }} | grep "CN=${{ env.TRUSTSTORE_COMMON_NAME }}" | |
if: ${{ failure() }} | |
run: keytool -v -list -keystore truststore.p12 -storepass ${{ secrets.TRUSTSTORE_PASSWORD }} |
.github/workflows/test.yaml
Outdated
- uses: helm/kind-action@v1 | ||
with: | ||
cluster_name: kind | ||
- run: kind load docker-image java-spiffe-helper:test --name kind | ||
- run: helm upgrade --install -n spire-server spire-crds spire-crds --repo https://spiffe.github.io/helm-charts-hardened/ --create-namespace | ||
- run: | | ||
helm upgrade --install -n spire-server spire spire \ | ||
--repo https://spiffe.github.io/helm-charts-hardened/ \ | ||
-f .github/tests/spire-values.yaml \ | ||
--set spire-server.ca_subject.common_name="$TRUSTSTORE_COMMON_NAME" \ | ||
--set spire-server.controllerManager.identities.clusterSPIFFEIDs.java-spiffe-helper.dnsNameTemplates[0]="$KEYSTORE_COMMON_NAME" | ||
- run: kubectl apply -f .github/tests/java-spiffe-helper.yaml | ||
- run: kubectl wait pod/java-spiffe-helper --for condition=Ready --timeout=90s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section could benefit from added clarity through the use of descriptive step names and breaking down complex commands for better readability:
Suggestion:
- uses: helm/kind-action@v1 | |
with: | |
cluster_name: kind | |
- run: kind load docker-image java-spiffe-helper:test --name kind | |
- run: helm upgrade --install -n spire-server spire-crds spire-crds --repo https://spiffe.github.io/helm-charts-hardened/ --create-namespace | |
- run: | | |
helm upgrade --install -n spire-server spire spire \ | |
--repo https://spiffe.github.io/helm-charts-hardened/ \ | |
-f .github/tests/spire-values.yaml \ | |
--set spire-server.ca_subject.common_name="$TRUSTSTORE_COMMON_NAME" \ | |
--set spire-server.controllerManager.identities.clusterSPIFFEIDs.java-spiffe-helper.dnsNameTemplates[0]="$KEYSTORE_COMMON_NAME" | |
- run: kubectl apply -f .github/tests/java-spiffe-helper.yaml | |
- run: kubectl wait pod/java-spiffe-helper --for condition=Ready --timeout=90s | |
- name: Setup Kubernetes in Docker (KIND) | |
uses: helm/kind-action@v1 | |
with: | |
cluster_name: kind | |
- name: Load Docker Image into KIND | |
run: kind load docker-image java-spiffe-helper:test --name kind | |
- name: Install SPIRE CRDs via Helm | |
run: helm upgrade --install -n spire-server spire-crds spire-crds --repo https://spiffe.github.io/helm-charts-hardened/ --create-namespace | |
- name: Configure and Install SPIRE Server | |
run: | | |
helm upgrade --install -n spire-server spire spire \ | |
--repo https://spiffe.github.io/helm-charts-hardened/ \ | |
-f .github/tests/spire-values.yaml \ | |
--set spire-server.ca_subject.common_name="$TRUSTSTORE_COMMON_NAME" \ | |
--set spire-server.controllerManager.identities.clusterSPIFFEIDs.java-spiffe-helper.dnsNameTemplates[0]="$KEYSTORE_COMMON_NAME" | |
- name: Apply java-spiffe-helper Kubernetes Configuration | |
run: kubectl apply -f .github/tests/java-spiffe-helper.yaml | |
- name: Wait for java-spiffe-helper Pod Readiness | |
run: kubectl wait pod/java-spiffe-helper --for condition=Ready --timeout=90s |
Hey @moritzschmitz-oviva, thanks a lot for this contribution! I've reviewed the changes, left a few comments and have a couple of additional suggestions:
In addition, I believe it's important to cover all supported LTS versions of Java to ensure compatibility. Could we update the job configuration to test against the following Java versions?
|
Signed-off-by: Moritz Schmitz von Hülst <[email protected]>
Done
Done
I don't think this is necessary. The |
You are completely right! |
Hey @moritzschmitz-oviva, this PR looks good! I agree with the point you raised in the 'topics to discuss' about pinning the chart version. It's definitely a good practice that can enhance the stability of the test. Looking forward to seeing this adjustment. As for the CN verification, it appears to be sufficient for the scope of this functional test. I'm particularly interested in seeing the java-spiffe-helper in action storing certificates in a JKS file, and then ensuring the expected cert is stored. |
Signed-off-by: Moritz Schmitz von Hülst <[email protected]>
Signed-off-by: Moritz Schmitz von Hülst <[email protected]>
Signed-off-by: Moritz Schmitz von Hülst <[email protected]>
Adjusted the workflow. Perhaps over-engineered it a bit now. Adding additional chart versions should be straight forward for testing. I didn't pin the patch, because according to SemVer, patches must be backwards compatible changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Thanks, @moritzschmitz-oviva !
Closes #200
java-spiffe-helper
container using the latest changes on the branch.kind
cluster and load the previously built image into it.spire-server
chart with dependencies. Set special values for theCN
in the certificates. This is what we later test.java-spiffe-helper
container and let it do its magic.*.jks
files and verify theCN
values set earlier.Potential discussion topics:
spire
charts. Perhaps pin the version here?CN
. Anything else to check for? For example the properties are using hard-coded values. Could also make them dynamic.